package org.example;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;

import java.time.Duration;

public class JedisConnectionFactory {
    private static JedisPool jedisPool;


    static {
        JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
        jedisPoolConfig.setMaxIdle(8);
        jedisPoolConfig.setMinIdle(2);
        jedisPoolConfig.setMaxTotal(8);
        jedisPoolConfig.setMaxWait(Duration.ofSeconds(10));


        jedisPool = new JedisPool(jedisPoolConfig,"10.13.4.50",6379,1000,"hxpti123",0);
    }

    public static Jedis getJedis(){
        return jedisPool.getResource();
    }
}
